#!/bin/sh

PORT_NUM=$1
#sed -i 's|^Port_Number=[1-2]|Port_Number='$PORT_NUM'|g' video_in.conf

if [ "$PORT_NUM" == "1" ] ; then
	sed -i 's|^Port0_Sensor_Clock=0:\([0-9]*\)|Port0_Sensor_Clock=0:20|g' video_in.conf
	sed -i 's|^Port1_Enable=1:\([0-9]*\)|Port1_Enable=1:0|g' video_in.conf
	sed -i 's|^Pipe1_Resolution=1:\([0-9x]*\)|Pipe1_Resolution=1:640x480|g' video_in.conf
	#sed -i 's|^Pipe1_Color_Type=1:\([0-9]*\)|Pipe1_Color_Type=1:1|g' video_in.conf
	
	sed -i 's|^Pipe2|#Pipe2|g' video_in.conf
	sed -i 's|^Pipe3|#Pipe3|g' video_in.conf
	sed -i 's|^Port1|#Port1|g' video_in.conf

	sed -i 's|^Pipe2|#Pipe2|g' jpeg_encoder.conf
	sed -i 's|^Pipe3|#Pipe3|g' jpeg_encoder.conf
	
	sed -i 's|^Pipe1|#Pipe1|g' h264_encoder.conf
elif [ "$PORT_NUM" == "2" ] ; then
	sed -i 's|^Port0_Sensor_Clock=0:\([0-9]*\)|Port0_Sensor_Clock=0:16|g' video_in.conf
	sed -i 's|^Port1_Enable=1:\([0-9]*\)|Port1_Enable=1:1|g' video_in.conf
	sed -i 's|^Pipe1_Resolution=1:\([0-9x]*\)|Pipe1_Resolution=1:320x240|g' video_in.conf
	#sed -i 's|^Pipe1_Color_Type=1:\([0-9]*\)|Pipe1_Color_Type=1:1|g' video_in.conf
	
	sed -i 's|^#Pipe2|Pipe2|g' video_in.conf
	sed -i 's|^#Pipe3|Pipe3|g' video_in.conf
	sed -i 's|^#Port1|Port1|g' video_in.conf

	sed -i 's|^#Pipe2|Pipe2|g' jpeg_encoder.conf
	sed -i 's|^#Pipe3|Pipe3|g' jpeg_encoder.conf

	sed -i 's|^#Pipe1|Pipe1|g' h264_encoder.conf
else
	echo "Usage: $0 [1|2]"
fi

